SHELL := /bin/bash
PATH  := node_modules/.bin:$(PATH)
VIRTUALENV_DIR := .venv
EXEC := ${VIRTUALENV_DIR}/bin/python main.py

help:
	@echo "  server      启动 server"
	@echo "  pip         初始化后端 python 环境"
	@echo "  clean       清理 .pyc 文件"
	@echo "  daemon      以守护进程启动"
	@echo "  status      查看进程"
	@echo "  stop        停止程序"


pip:
	pip install virtualenv
	virtualenv $(VIRTUALENV_DIR)
	$(VIRTUALENV_DIR)/bin/pip install -r requirements.txt -i https://pypi.douban.com/simple/
	mkdir -p logs

s server:
	${EXEC}

daemon:
	setsid ${EXEC} &
	sleep 1
	ps aux | grep -v grep | grep --colour=auto "${EXEC}"

status:
	ps aux | grep -v grep | grep --colour=auto "${EXEC}"

stop:
	kill `ps aux | grep "${EXEC}" | grep -v "grep" | awk '{print $$2}'`

clean:
	$(VIRTUALENV_DIR)/bin/python manage.py clean

#.PHONY: docs test
